﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;

namespace TRPOP.Controls
{
    /// <summary>
    /// CheckBox
    /// </summary>
    public class CheckBox : System.Web.UI.WebControls.CheckBox
    {
        /// <summary>
        /// 
        /// </summary>
        public string CommandName
        {
            get
            {
                if (this.ViewState["CommandName"] == null)
                { return string.Empty; }
                else
                {
                    return this.ViewState["CommandName"] as string;
                }
            }
            set
            {
                this.ViewState["CommandName"] = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public string CommandArgument
        {
            get
            {
                if (this.ViewState["CommandArgument"] == null)
                {
                    return string.Empty;
                }
                else
                {
                    return this.ViewState["CommandArgument"] as string;
                }
            }
            set
            {
                this.ViewState["CommandArgument"] = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="e"></param>
        protected override void OnCheckedChanged(EventArgs e)
        {
            //create a new event args of type command event args  
            CommandEventArgs ce = new CommandEventArgs(this.CommandName, this.CommandArgument);
            //allow the base checkbox to handle the event as normal 
            base.OnCheckedChanged(e);
            //raise the contorls method RaiseBubbleEvent  
            base.RaiseBubbleEvent(this, ce);
        }
    }
}
